package com.aruba.databinding2;

import android.util.Log;
import android.widget.Toast;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

/**
 * Created by aruba on 2021/9/11.
 */
public class UserViewModel extends BaseObservable {
    private static final String TAG = UserViewModel.class.getSimpleName();
    private User user;

    public UserViewModel() {
        user = new User("张三");
    }

    @Bindable
    public String getUserName() {
        return user.userName;
    }

    public void setUserName(String userName) {
        if (userName != null && !userName.equals(getUserName())) {
            user.userName = userName;
            notifyPropertyChanged(BR.userName);
            Log.i(TAG, userName);
        }
    }
}
